<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP '2.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<%@include file="/jsp/base.jsp"%>	
	<script type="text/javascript">
		$(function(){
		
			function appendTo(dest){
				var all_height=75;
				var height=250;
				var width=1000;
				var position;
				var all = $("#all").val();
				var alls = all.split(",");
				for(var i=0;i<alls.length;i++){
					var t = $("#"+alls[i]).dialog("isOpen");
					alert("t:"+t);
					if(t){
						height = parseInt($("#"+alls[i]).dialog("option","height"));
						width = $("#"+alls[i]).dialog("option","width");
						all_height = height + all_height;
						position = $("#"+alls[i]).dialog("option","position");
					
					}
				}
				alert("position:"+position);
				$("#" + dest).dialog("option","width",width);
				$("#" + dest).dialog("option","height",height);
				if(!position){
					$("#" + dest).dialog("option","position",[10,all_height])	;
				}else {
					$("#" + dest).dialog("option","position",[position[0],all_height])	;
				}
				
			}
		
			$("#opencpu").click(function(){
				appendTo("cpu");
				$("#cpu").dialog("open");
			});
			
			$("#openrom").click(function(){
				appendTo("rom");
				$("#rom").dialog("open");
			});
		
			$("#cpu").dialog({
			autoOpen:false, 
			show : {
				effect: "blind",
				duration: 1000	
			},
			hide : {
				duration: 1000,
			},
			width : 650,
			height : 450,
			position:[10,50]
			});
			
			$("#rom").dialog({
				autoOpen:false, 
				show : {
					effect: "blind",
					duration: 1000	
				},
				hide : {
					duration: 1000,
				},
				width : 650,
				height : 450,
				position:[10,50]
			});
		})
	</script>
  </head>
  
  <body>
    <div id="cpu" title="CPU"></div>
  	<div id="rom" title="ROM"></div>
  	<input type="hidden" id="all" value="cpu,rom" />
  	<button id="opencpu">CPU</button>
  	<button id="openrom">ROM</button>  
  </body>
</html>
